//
//  LBCropConfig.h
//  LBCropImagePage
//
//  Created by mac on 2024/6/2.
//
// 宽度

#define SCREEN_WIDTH            ([UIScreen mainScreen].bounds.size.width)

// 高度

#define SCREEN_HEIGHT           ([UIScreen mainScreen].bounds.size.height)



#define kIs_iPhoneX SCREEN_WIDTH >=375.0f && SCREEN_HEIGHT >=812.0f

#define kTopBarSafeHeight (CGFloat)(kIs_iPhoneX?(44.0):(0))


#define kBottomSafeHeight (CGFloat)(kIs_iPhoneX?(34.0):(0))

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

#define adapt375(m) [UIScreen mainScreen].bounds.size.width/375.0 * m
#define WEAKSELF               __weak typeof(self) weakSelf = self;

///旋转基准角度0°/360°、90°， 180°， 270°
typedef NS_ENUM(NSUInteger, kCropOriginAngle) {
    kCropOriginAngle0,  ///以0°/360°为基准，可旋转范围 `-45°~45°`
    kCropOriginAngle90, ///以90°为基准，可旋转范围， `45° ~ 135°`
    kCropOriginAngle180, ///以180°为基准， 可旋转范围    `135° ~ 225°
    kCropOriginAngle270, ///以270° 为基准，可旋转范围  `225° ~ 315°`
};

typedef struct {
    NSInteger verCount;
    NSInteger horCount;
} BMGridCount;

static inline BMGridCount BMGridCountMake(CGFloat verCount, CGFloat horCount)
{
    BMGridCount gridCount;
    gridCount.verCount = verCount;
    gridCount.horCount = horCount;
    return gridCount;
}

//static inline CGFloat safeBottomHeight(void) {
//    if (@available(iOS 11.0, *)) {
//        CGFloat height = [[UIApplication sharedApplication] delegate].win.safeAreaInsets.bottom;
//        return height;
//    } else {
//        return 0;
//    }
//}

typedef NS_ENUM(NSUInteger, kCropRatioType) {
    kCropRatioTypeOri,
    kCropRatioType11,
    kCropRatioType34,
    kCropRatioType43,
    kCropRatioType916,
};

NS_ASSUME_NONNULL_BEGIN

@interface LBCropConfig : NSObject <NSCoding>

//是否编辑过
@property (nonatomic, assign) BOOL modified;

///裁剪图片
@property (nonatomic, strong) UIImage *image;

//裁剪图片localid
@property (nonatomic, copy) NSString *imageLocalId;
//裁剪宽高比
@property (nonatomic, assign) CGFloat cropWHRatio;
//裁剪固定比例类型
@property (nonatomic, assign) kCropRatioType cropRatioType;
//旋转基准急角度 0°/360°、90°、180°、270°
@property (nonatomic, assign) kCropOriginAngle originAngle;

///调整的旋转角度 （基于 `originAngle`, 范围`-45° ~ 45°`）
@property (nonatomic, assign) CGFloat angle;

///裁剪时的缩放比例
@property (nonatomic, assign) CGFloat zoomScale;

//裁剪时的偏移量
@property (nonatomic, assign) CGPoint contentOffset;

- (instancetype)initWithImgae:(UIImage *)image
                  cropWHRatio:(CGFloat)cropWHRatio
                  originAngle:(kCropOriginAngle)originAngle
                        angle:(CGFloat)angle
                    zoomScale:(CGFloat)zoomScale
                contentOffset:(CGPoint)contentOffset;

@end

NS_ASSUME_NONNULL_END
